#include "led.h"
#include "io.h"


Led_Mode_t Led_CurrentMode = LED_OFF;
uint32 Led_Counter = 0;


#define Led_Set()    IO_Set(0, 1)
#define Led_Reset()  IO_Set(0, 0)


void Led_Ini(void)
{
	Led_Reset();
	Led_SetMode(LED_OFF);
}


void Led_MainFunction(void)
{
	switch(Led_CurrentMode)
	{
		case LED_OFF:
		{
			Led_Reset();
		}
		break;

		case LED_ON:
		{
			Led_Set();
		}
		break;

		case LED_BLINK_1S:
		{
			if(Led_Counter < 5)
			{
				Led_Set();
			}
			else
			{
				Led_Reset();
			}
		}
		break;

		case LED_FLASH_1S:
		{
			if(Led_Counter < 1)
			{
				Led_Set();
			}
			else
			{
				Led_Reset();
			}
		}
		break;

		case LED_BLINK_05S:
		case LED_FLASH_05S:
		{
		}
		break;
	}
	
	if(Led_Counter < 10)
	{
		Led_Counter++;
	}
	else
	{
		Led_Counter = 0;
	}
}


void Led_SetMode(Led_Mode_t mode)
{
	Led_Counter = 0;
	Led_CurrentMode = mode;
}


